package com.yanfan.passengerFlow.controller;

import java.util.Arrays;
import java.util.List;
import javax.validation.Valid;
import javax.servlet.http.HttpServletResponse;
import com.yanfan.common.utils.DateUtils;
import com.yanfan.common.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yanfan.common.annotation.Log;
import com.yanfan.common.core.controller.BaseController;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.enums.BusinessType;
import com.yanfan.passengerFlow.domain.IbmsPassengerFlowStatistics;
import com.yanfan.passengerFlow.service.IIbmsPassengerFlowStatisticsService;
import com.yanfan.common.utils.poi.ExcelUtil;
import com.yanfan.common.core.page.TableDataInfo;

/**
 * 客流数据Controller
 *
 * @author genluo
 * @date 2024-08-26
 */
@Api(tags = "客流数据")
@RestController
@RequestMapping("/passengerFlow/passengerFlowStatistics")
public class IbmsPassengerFlowStatisticsController extends BaseController {
    @Autowired
    private IIbmsPassengerFlowStatisticsService ibmsPassengerFlowStatisticsService;

    /**
     * 查询客流数据列表
     */
    @ApiOperation("客流数据分页列表")
    @PreAuthorize("@ss.hasPermi('passengerFlow:passengerFlowStatistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(IbmsPassengerFlowStatistics ibmsPassengerFlowStatistics) {
        startPage();
        List<IbmsPassengerFlowStatistics> list = ibmsPassengerFlowStatisticsService.selectIbmsPassengerFlowStatisticsList(ibmsPassengerFlowStatistics);
        return getDataTable(list);
    }

    /**
     * 导出客流数据列表
     */
    @ApiOperation("导出客流数据列表")
    @PreAuthorize("@ss.hasPermi('passengerFlow:passengerFlowStatistics:export')")
    @Log(title = "客流数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IbmsPassengerFlowStatistics ibmsPassengerFlowStatistics) {
        List<IbmsPassengerFlowStatistics> list = ibmsPassengerFlowStatisticsService.selectIbmsPassengerFlowStatisticsList(ibmsPassengerFlowStatistics);
        ExcelUtil<IbmsPassengerFlowStatistics> util = new ExcelUtil<IbmsPassengerFlowStatistics>(IbmsPassengerFlowStatistics.class);
        util.exportExcel(response, list, "客流数据数据");
    }

    /**
     * 获取客流数据详细信息
     */
    @ApiOperation("获取客流数据详细信息")
    @PreAuthorize("@ss.hasPermi('passengerFlow:passengerFlowStatistics:query')")
    @GetMapping(value = "/{statId}")
    public AjaxResult getInfo(@PathVariable("statId") Long statId) {
        return success(ibmsPassengerFlowStatisticsService.getById(statId));
    }

    /**
     * 新增客流数据
     */
    @ApiOperation("新增客流数据")
    @PreAuthorize("@ss.hasPermi('passengerFlow:passengerFlowStatistics:add')")
    @Log(title = "客流数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Valid @RequestBody IbmsPassengerFlowStatistics ibmsPassengerFlowStatistics) {
        return toAjax(ibmsPassengerFlowStatisticsService.save(ibmsPassengerFlowStatistics));
    }

    /**
     * 修改客流数据
     */
    @ApiOperation("修改客流数据")
    @PreAuthorize("@ss.hasPermi('passengerFlow:passengerFlowStatistics:edit')")
    @Log(title = "客流数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Valid @RequestBody IbmsPassengerFlowStatistics ibmsPassengerFlowStatistics) {
        return toAjax(ibmsPassengerFlowStatisticsService.updateById(ibmsPassengerFlowStatistics));
    }

    /**
     * 删除客流数据
     */
    @ApiOperation("删除客流数据")
    @PreAuthorize("@ss.hasPermi('passengerFlow:passengerFlowStatistics:remove')")
    @Log(title = "客流数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{statIds}")
    public AjaxResult remove(@PathVariable Long[] statIds) {
        return toAjax(ibmsPassengerFlowStatisticsService.removeBatchByIds(Arrays.asList(statIds)));
    }
}
